#!/bin/sh

# 设置 safe.directory
git config --global --add safe.directory /reseed-puppy-php

# 切换到项目目录
cd /reseed-puppy-php

# 更新代码
git update-index --skip-worktree database/sqlite.db
git fetch --all
git reset --hard origin/master
git pull

# 执行更新数据库指令
php /reseed-puppy-php/think migrate:run

# 复制 run.sh
cp /reseed-puppy-php/run.sh /scripts/run.sh
chmod -R 777 /scripts/run.sh

# 启动应用
php /reseed-puppy-php/think run -p1919 "$@" &
php /reseed-puppy-php/think xadmin:queue start "$@" &

# 保持容器运行
tail -f /dev/null